package services

import (
	"context"
	"github.com/cloudwego/hertz/pkg/common/hlog"
	"gorm.io/gen"
	"mall_frontend_api/biz/dal"
	"mall_frontend_api/biz/handler/base"
	"mall_frontend_api/biz/model/setting"
	"mall_frontend_api/biz/pack"
)

type SettingService struct {
	ctx    context.Context
	common *base.Response
	dao    *dal.InitDAO
}

func NewSettingService(ctx context.Context, common *base.Response) *SettingService {
	return &SettingService{ctx: ctx, common: common, dao: dal.NewInitDAO()}
}

func (c *SettingService) GetContactUsSelect(req *setting.GetContactUsSelectRequest) ([]*setting.ContactUsOption, error) {
	list, err := c.dao.ContactUsOptionDAO.GetList(c.ctx, []gen.Condition{}, 0, 0)
	if err != nil {
		hlog.CtxErrorf(c.ctx, "GetContactUsSelect error: %v", err)
		return nil, err
	}

	return pack.ContactUsOption(list), nil
}
